package com.meida.module.marketing.provider.controller;

import com.meida.common.mybatis.model.*;
import com.meida.common.springmvc.base.BaseController;
import com.meida.module.marketing.client.entity.MkgCoupon;
import com.meida.module.marketing.provider.service.CouponService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


/**
 * 优惠券控制器
 *
 * @author flyme
 * @date 2019-10-22
 */
@RestController
@RequestMapping("/coupon/")
@Api(tags = "优惠券管理")
public class CouponController extends BaseController<CouponService, MkgCoupon> {

    @ApiOperation(value = "优惠券-分页列表", notes = "分页列表")
    @GetMapping(value = "page")
    public ResultBody page(@RequestParam(required = false) Map map) {
        return bizService.pageList(map);
    }


    @ApiOperation(value = "优惠券-列表", notes = "优惠券列表")
    @GetMapping(value = "list")
    public ResultBody list(@ModelAttribute(value = "listModel") ListModel listModel) {
        return bizService.listEntityMap(listModel);
    }

    @ApiOperation(value = "优惠券-添加", notes = "优惠券添加")
    @PostMapping(value = "save")
    public ResultBody save(SaveModel saveModel) {
        return bizService.add(saveModel);
    }

    @ApiOperation(value = "优惠券-更新", notes = "优惠券更新")
    @PostMapping(value = "update")
    public ResultBody update(@ModelAttribute(value = "model") UpdateModel model) {
        return bizService.edit(model);
    }

    @ApiOperation(value = "优惠券-删除", notes = "优惠券删除")
    @PostMapping(value = "delete")
    public ResultBody delete(@ModelAttribute(value = "deleteModel") DeleteModel deleteModel) {
        return bizService.delete(deleteModel);
    }


    @ApiOperation(value = "优惠券-详情", notes = "优惠券详情")
    @GetMapping(value = "get")
    public ResultBody get(@ModelAttribute(value = "getModel") GetModel getModel) {
        return bizService.get(getModel);
    }
}
